package com.markpim.dena.opdracht4;

import java.util.Map;
import java.util.Map.Entry;

public class PERTNetwerk {

	public static void main(String[] args) {
		System.out.println("regular input:\n");
		doRegularInput();
		System.out.println("\ntest input:\n");
		doTestInput();
		System.out.println("\nloop input:\n");
		doLoopInput();
	}
	
	private static void doRegularInput() {
		GenericGraph pert = new GenericGraph();

		pert.addVertex("A");
		pert.addVertex("B");
		pert.addVertex("C");
		pert.addVertex("D");
		pert.addVertex("E");
		pert.addVertex("F");
		pert.addVertex("G");

		pert.addEdge("B", "F", 1);
		pert.addEdge("B", "C", 1);
		pert.addEdge("D", "E", 1);
		pert.addEdge("E", "F", 1);
		pert.addEdge("A", "G", 3);
		pert.addEdge("F", "C", 1);
		pert.addEdge("A", "D", 1);
		pert.addEdge("G", "F", 2);
		pert.addEdge("A", "B", 3);

		pert.createInputCount();

		Map<String, Integer> minimums = pert.vroegsteTijden();
		for (Entry<String, Integer> minimum : minimums.entrySet()) {
			System.out.println("\tMinimum of " + minimum.getKey() + ": " + minimum.getValue());
		}

		System.out.println();
		
		pert.createOutputCount();
		
		Map<String, Integer> maximums = pert.laatsteTijden();
		for (Entry<String, Integer> maximum : maximums.entrySet()) {
			System.out.println("\tMaximum of " + maximum.getKey() + ": " + maximum.getValue());
		}
	}
	
	private static void doTestInput() {
		GenericGraph pert = new GenericGraph();

		pert.addVertex("A");
		pert.addVertex("B");
		pert.addVertex("C");
		pert.addVertex("D");
		pert.addVertex("E");
		pert.addVertex("F");
		pert.addVertex("G");
		pert.addVertex("H");
		pert.addVertex("I");

		pert.addEdge("B", "F", 1);
		pert.addEdge("B", "C", 1);
		pert.addEdge("D", "E", 1);
		pert.addEdge("E", "F", 1);
		pert.addEdge("A", "G", 3);
		pert.addEdge("F", "C", 1);
		pert.addEdge("A", "D", 1);
		pert.addEdge("G", "F", 2);
		pert.addEdge("A", "B", 3);
		pert.addEdge("H", "B", 5);
		pert.addEdge("F", "I", 1);
		pert.addEdge("G", "I", 5);

		pert.createInputCount();

		Map<String, Integer> minimums = pert.vroegsteTijden();
		for (Entry<String, Integer> minimum : minimums.entrySet()) {
			System.out.println("\tMinimum of " + minimum.getKey() + ": " + minimum.getValue());
		}

		System.out.println();
		
		pert.createOutputCount();
		
		Map<String, Integer> maximums = pert.laatsteTijden();
		for (Entry<String, Integer> maximum : maximums.entrySet()) {
			System.out.println("\tMaximum of " + maximum.getKey() + ": " + maximum.getValue());
		}
	}
	
	private static void doLoopInput() {
		GenericGraph pert = new GenericGraph();

		pert.addVertex("A");
		pert.addVertex("B");
		pert.addVertex("C");
		pert.addVertex("D");
		pert.addVertex("E");
		pert.addVertex("F");
		pert.addVertex("G");
		pert.addVertex("H");
		pert.addVertex("I");

		pert.addEdge("B", "F", 1);
		pert.addEdge("B", "C", 1);
		pert.addEdge("D", "E", 1);
		pert.addEdge("E", "F", 1);
		pert.addEdge("A", "G", 3);
		pert.addEdge("F", "C", 1);
		pert.addEdge("A", "D", 1);
		pert.addEdge("G", "F", 2);
		pert.addEdge("A", "B", 3);
		pert.addEdge("H", "B", 5);
		pert.addEdge("F", "I", 1);
		pert.addEdge("G", "I", 5);
		
		//de edge die voor een loop zal zorgen
		pert.addEdge("I", "G", 1);

		pert.createInputCount();

		Map<String, Integer> minimums = pert.vroegsteTijden();
		for (Entry<String, Integer> minimum : minimums.entrySet()) {
			System.out.println("\tMinimum of " + minimum.getKey() + ": " + minimum.getValue());
		}

		System.out.println();
		
		pert.createOutputCount();
		
		Map<String, Integer> maximums = pert.laatsteTijden();
		for (Entry<String, Integer> maximum : maximums.entrySet()) {
			System.out.println("\tMaximum of " + maximum.getKey() + ": " + maximum.getValue());
		}
	}

}
